package org.apache.lucene.ocean.log;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;

/**
 * Log record header
 *
 */
public class RecordHeader implements Comparable<RecordHeader> {
  public long id;
  public int headerPosition;
  public int headersLength;
  public int docsLength;
  public int docType;
  public int otherLength;
  public int otherType;
  //public int docsPosition;
  public long docsCrc32;
  public long otherCrc32;
  
  public int getLength() {
    return headersLength + docsLength + otherLength;
  }
  
  public long getDocsPosition() {
    return headerPosition + headersLength;
  }
  
  public long getOtherPosition() {
    return headerPosition + headersLength + docsLength;
  }
  
  public int compareTo(RecordHeader other) {
    return (id < other.id ? -1 : (id == other.id ? 0 : 1));
  }

  public String toString() {
    return ReflectionToStringBuilder.toString(this);
  }
}